#include <common_def.h>
#include <cmath>
#include <Square.h>


Square::Square(double side)
{
	side_m = FLOOR2(side);
}

bool Square::isValid() const
{
	return IN_RANGE(side_m, 0, 75);
}

double Square::getArea() const
{
	double area = ROUND2(side_m*side_m);
	return isValid() ? area : INVALID_VALUE_FOR_SQUARE;
}

double Square::getPerimeter() const
{
	double perimeter = ROUND2(4*side_m);
	return isValid() ? perimeter : INVALID_VALUE_FOR_SQUARE;
}

bool Square::setSide(double side)
{
	side_m = FLOOR2(side);
	return IN_RANGE(side_m, 0, 75);
}